package org.xgluo.services;

/**
 * 声明式事务: 注解配置
 * 配置类中通过注解@EnableTransaction开启事务管理
 */

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserDemoServiceConfig2 {

    @Autowired
    JdbcTemplate jdbcTemplate;

    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public void updateUserInfo(){

        jdbcTemplate.update("update infouser set name='123' where iduser='123' ");

    }

    @Transactional
    public void updateUserInfo1(){
        updateUserInfo();
        jdbcTemplate.update("update infouser set name='124' where iduser='124' ");
        int i= 2/0;
    }

}
